import dayjs from 'dayjs';

export default dayjs;

// export const formatter = 'YYYY-MM-DD HH:mm:ss';

export const formatDate = (date, fmtType = 1) => {
  let formatter = 'YYYY-MM-DD HH:mm:ss';
  if (fmtType === 1) {
    formatter = 'YYYY-MM-DD HH:mm:ss';
  }
  if (fmtType === 2) {
    formatter = 'YYYY-MM-DD';
  }
  date = dayjs(date);
  if (!date.isValid()) {
    return;
  }
  return date.format(formatter);
};
